const changeData = function(timestamp, n=6) {

  let update = new Date(timestamp);
  //时间戳要乘1000
  let year = update.getFullYear();
  let month = (update.getMonth() + 1 < 10) ? ('0' + (update.getMonth() + 1)) : (update.getMonth() + 1);
  let day = (update.getDate() < 10) ? ('0' + update.getDate()) : (update.getDate());
  let hour = (update.getHours() < 10) ? ('0' + update.getHours()) : (update.getHours());
  let minute = (update.getMinutes() < 10) ? ('0' + update.getMinutes()) : (update.getMinutes());
  let second = (update.getSeconds() < 10) ? ('0' + update.getSeconds()) : (update.getSeconds());
  if (n == 1) {
    return (year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);
  } else if (n == 2) {
    return (year + '-' + month + '-' + day);
  } else if (n == 3) {
    return (month + '-' + day);
  } else if (n == 4) {
    return (hour + ':' + minute);
  }
  else if (n == 5) {
    return (hour + ':' + minute + ':' + second);
  } else if (n == 6) {
    return (year + '-' + month + '-' + day + ' ' + hour + ':' + minute);
  }else {
    return 0;
  }
}
export default changeData